#ifndef __IS_CORE_RAYTRACE_KDTREE__
#define __IS_CORE_RAYTRACE_KDTREE__

namespace IS
{

/*! KdTree is mainly used for closest point caching
*/
class KdTree
{
public:
    
    struct Entry
    {
    // Construction
        Entry(const Vec3f& _position, void* _data)
            : position(_position), data(_data)
        {}
        
    // Attribute
        Vec3f position;
        void* data;
    };

    struct Impl;
    Impl * mImpl;

public:
    KdTree();
    
    ~KdTree();
    
    /*! Adds a new entry, no duplicate-check is performed
    */
    void addEntry(const Entry& entry);
    
    /*! Returns NULL if this KdTree is empty;
        otherwise the closest entry to the refPoint.
    */
    Entry* closest(const Vec3f& refPoint);

};	// KdTree

}	// namespace IS

#endif  // __IS_CORE_RAYTRACE_KDTREE__